package org.darkforest.common.services;

import org.darkforest.model.*;
import org.darkforest.vo.MemberBase;
import org.darkforest.vo.PayInfoVo;
import org.darkforest.vo.WxUserDetailInfo;
import org.darkforest.vo.WxUserInfo;
import org.jdom.JDOMException;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by valentina on 15/7/12.
 * 支付相关操作类
 */
public interface WxJSSdkService {

    /**
     * 获取accesstoken，获取之后缓存在redis，减少请求次数
     * @return
     * @throws Exception
     */
    public String getAccessToken(String inMode) throws Exception;

    /**
     * 获取
     * @return
     */
    public WxUserInfo getUserAccessToken(String code);

    public WxUserInfo getQYUserAccessToken(String code);

//    public String getUserOpenId(String code);

    public WxUserDetailInfo getUserDetail(String user_access_token, String openid);

    /**
     * 获取jsapi_ticket，验签使用，获取之后缓存在redis，减少请求次数
     * @return
     * @throws Exception
     */
    public String getJsapiTicket(String access_token, String inMode) throws Exception;

    /**
     * 获取js验权签名
     * @param noncestr
//     * @param ticket
     * @param url
     * @return
     */
    public String getJsSignature(String noncestr, String url, String timeStamp, String inMode) throws Exception;



    /**
     * 生成微信支付数据
     * @param code
     * @param openid
     * @param order
     * @return
     * @throws Exception
     */
    public Map getJsApiPay(String code, String openid, OrderSearchBean order, String basePath) throws Exception;

    public boolean isWXSign(String TOKEN, String timestamp, String nonce, String signature);

    /**
     * 获取会员二维码,并上传图片到服务器
     * @param memberId
     * @return
     */
    public String getMemberQRImg(String memberId, String avatar, String tmp);

    public String getQRImgValidTime(Integer userId);

    /**
     * 微信退款
     * @param refund
     * @return
     */
    boolean wxRefund(RefundReturn refund,Order order);



    /**
     * 扫码支付接口
     * @param order
     * @return
     */
    Map<String,String> getWxScanPayUrl(OrderSearchBean order) throws Exception;


    /**
     * web端扫码支付接口
     * @param
     * @return
     */
    Map<String,String> getPCWxScanPayUrl(OrderVo orderVo,PayInfoVo payInfo) throws Exception;

    public void sendWechatMessage(String openId,String text);


    /**
     * 生成微信充值支付数据
     * @param code
     * @param pdRecharge
     * @return
     * @throws Exception
     */
//    public Map getJsApiPayForRecharge(String code, PdRecharge pdRecharge, String basePath) throws Exception;
    public Map getJsApiPayForRecharge(String code, PdRecharge pdRecharge) throws Exception;

    Map<String,String> getJsApiPayParams(List<OrderVo> orderVos, String openId, String basePath) throws Exception;

    Map<String,String> getH5PayParams(HttpServletRequest request, List<OrderVo> orderVos, String openId, String orderBatchNumber) throws Exception;
}
